package com.glodon.zhuanli.common.sms;

import com.glodon.zhuanli.common.UtilRandomNum;
import lombok.Getter;
import org.springframework.util.Assert;

public class SMSPasswordModify extends SMSTargetAdaptor {

    //验证码默认的长度
    public static final int VCODE_DEFAULT_LENGTH = 6 ;

    @Getter
    private int vcodeLength = VCODE_DEFAULT_LENGTH ;

    @Getter
    private String vcode ;

    public SMSPasswordModify(String mobile) {
        this(mobile , VCODE_DEFAULT_LENGTH ) ;
    }

    public SMSPasswordModify(String mobile , int vcodeLength) {
        super("修改密码" , "password_modify") ;
        Assert.isTrue(vcodeLength>1 , "修改密码的验证码长度大于1");
        this.vcodeLength = vcodeLength ;

        //添加发送短信的手机号
        this.addMobile( mobile ) ;

        //生成验证码
        this.vcode = UtilRandomNum.generateVerifyCode( vcodeLength ) ;
        this.addTemplateParam( "code" , this.vcode ) ;
    }

}
